﻿Imports CrystalDecisions.Shared
Imports System.Data.SqlClient

Public Class frmLDEC

    Private Sub btnGenerar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerar.Click
        Dim con As New ConexionBD
        Dim report As New rptLibroDiario
        Dim FechaDV, cant As New ParameterDiscreteValue
        Dim comando As SqlCommand
        Dim dr As SqlDataReader
        Dim conn As New SqlConnection

        With con
            .BasededatosP = "RecmetalSoft"
            .ServidorP = "192.168.0.100"
            .UsuarioP = "RecmetalSoftwareUser"
            .PasswordP = "RcmtlS0ft"
        End With


        comando = New SqlCommand("SP_REC_SaldoIniInventario3248", conn)
        comando.CommandType = CommandType.StoredProcedure
        comando.Parameters.AddWithValue("@ini", dtpFecha.Value)
        conn.Open()
        dr = comando.ExecuteReader

        dr.Read()
        cant.Value = CDbl(dr("102").ToString)
        report.SetParameterValue("@102", cant)
        cant.Value = CDbl(dr("103").ToString)
        report.SetParameterValue("@103", cant)
        cant.Value = CDbl(dr("104").ToString)
        report.SetParameterValue("@104", cant)
        cant.Value = CDbl(dr("105").ToString)
        report.SetParameterValue("@105", cant)
        cant.Value = CDbl(dr("106").ToString)
        report.SetParameterValue("@106", cant)
        cant.Value = CDbl(dr("107").ToString)
        report.SetParameterValue("@107", cant)
        conn.Close()

        con.BasededatosP = "Recmetal"
        report.DataSourceConnections(0).SetConnection(con.ServidorP, con.BasededatosP, "sa", "sa")
        FechaDV.Value = dtpFecha.Value
       
        report.SetParameterValue("@ini", FechaDV)
        report.SetParameterValue("@fin", FechaDV)

        crv1.ReportSource = report
        'SucursalDV.Value = cbSucursal.Text
        'report.SetParameterValue("@Sucursal", SucursalDV)
        'report.SetParameterValue("@Sucursal", SucursalDV, "rptResumenVtaNac.rpt")
        'crvVentas.ReportSource = report
    End Sub
End Class